package com.situ.crm.controller.back;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.crm.common.ServerResponse;
import com.situ.crm.entity.Customer;
import com.situ.crm.service.ICustomerService;

@Controller
@RequestMapping("/customer")
public class CustomerController {

	@Autowired
	private ICustomerService customerService; 
	//跳转到客户管理界面
	@RequestMapping("/getPage")
	public String getPage() {
		
		return "/customer/customer";
	}
	//查询所有客户信息
	@RequestMapping("/selectCustomerId")
	@ResponseBody
	public ServerResponse selectCustomer(){
		ServerResponse serverResponse = customerService.selectCustomer();
		
		return serverResponse;
	}
	//展示界面数据接口
	@RequestMapping("/pageList")
	@ResponseBody
	public ServerResponse pageList(Integer page,Integer limit) {
		ServerResponse serverResponse = customerService.pageList(page,limit);
		
		return serverResponse;
	}
	//跳转到添加界面
	@RequestMapping("/add")
	public String add () {
		
		return "/customer/customer_add";
	}
	//添加功能
	@RequestMapping("/insert")
	@ResponseBody
	public ServerResponse insert(Customer customer) {
		ServerResponse serverResponse = customerService.insert(customer);
		
		return serverResponse;
	}
	
}
